import {
  ChangeDetectionStrategy,
  Component,
  OnChanges,
  SimpleChanges,
} from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NzInputModule } from 'ng-zorro-antd/input';
import { NzToolTipModule } from 'ng-zorro-antd/tooltip';

@Component({
  selector: 'app-input-tooltip',
  standalone: true,
  imports: [NzInputModule, NzToolTipModule, FormsModule],
  template: `
    <div class="demo">
      <h1>aaa</h1>
      <input
        nz-input
        type="number"
        [(ngModel)]="value"
        (ngModelChange)="updateValueTip()"
        nz-tooltip
        [nzTooltipTitle]="valueTip"
        style="width: 80px;"
      />
    </div>
  `,
  // changeDetection: ChangeDetectionStrategy.OnPush,
})
export class InputTooltipComponent {
  value: number | null = null;
  private _valueTip = '';

  get valueTip() {
    return this._valueTip;
  }

  updateValueTip() {
    this._valueTip = this.getValueTipInternal();
  }

  private getValueTipInternal(): string {
    console.log('getValueTipInternal');
    return this.value?.toString() ?? '请输入数字';
  }
}
